package cn.fancy.sdk.pay.entity;

import org.json.JSONException;
import org.json.JSONObject;

import cn.fancy.sdk.entity.JsonParseInterface;

public class TelecomPay implements JsonParseInterface 
{
	
	private final String _propsId = "a";
	private final String _propsName = "b";
	private final String _payCode = "c";
	private final String _supportQuota = "d";
	private final String _money = "e";
	private final String _transId = "f";
	

	public String propsId = "";
	public String propsName = "";
	public String payCode = "";
	public int supportQuota = Integer.MIN_VALUE;
	public double money = 0.0;
	public String transId = "";
	
	
	


	@Override
	public void parseJson(JSONObject json) {

		if (json == null) return;
		
		propsId = json.optString(_propsId, "");

		propsName = json.optString(_propsName, "");

		payCode = json.optString(_payCode, "");

		supportQuota = json.optInt(_supportQuota, Integer.MIN_VALUE);

		money = json.optDouble(_money, 0.0);
		
		transId = json.optString(_transId, "");

	}
	
	@Override
	public String toString() {

		return "propsId="+propsId+",propsName="+propsName+",payCode="+payCode+",supportQuota="+supportQuota+",money="+money+",transId="+transId+"\n";
	}

	@Override
	public JSONObject buildJson() {
		
		try 
		{
			JSONObject json = new JSONObject();
			json.put(_propsId, propsId);
			json.put(_propsName, propsName);
			json.put(_payCode, payCode);
			json.put(_supportQuota, supportQuota);
			json.put(_money, money);
			json.put(_transId, transId);

			return json;
		} 
		catch (JSONException e) 
		{
			e.printStackTrace();
		}

		return null;
	}

	
	@Override
	public String getShortName() {

		return "TelecomPay";
	}

}
